home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-15 | 1.5 KB | 58 lines | [TEXT/PJMM] |
- unit MungeLibs;
-
- interface
-
- uses
- EPPC, AppleEvents;
-
- function UDecStr (n: longint): Str15;
- function FSReadQ (refnum: integer; count: longint; buf: Ptr): OSErr;
- function MyFSWriteAt (refnum: integer; mode: integer; pos, len: longInt; p: ptr): OSErr;
- function AEGetParamBoolean (event: AppleEvent; key: AEKeyword; var b: boolean): OSErr;
-
- implementation
-
- function UDecStr (n: longint): Str15;
- (* This horror is courtesy of Peter Lewis <peter.lewis@info.curtin.edu.au> *)
- var
- s: Str15;
- begin
- s := '';
- repeat
- s := concat(chr(48 + (n mod 10 + 10 + (6 * ord(n < 0))) mod 10), s);
- n := BAND(BSR(n, 1), $7FFFFFFF) div 5;
- until n = 0;
- UDecStr := s;
- end; (* UDecStr *)
-
- function FSReadQ (refnum: integer; count: longint; buf: Ptr): OSErr;
- begin
- FSReadQ := FSRead(refnum, count, buf);
- end; (* FSReadQ *)
-
- function MyFSWriteAt (refnum: integer; mode: integer; pos, len: longInt; p: ptr): OSErr;
- var
- pb: ParamBlockRec;
- oe: OSErr;
- begin
- pb.ioRefNum := refnum;
- pb.ioBuffer := p;
- pb.ioReqCount := len;
- pb.ioPosMode := mode;
- pb.ioPosOffset := pos;
- oe := PBWriteSync(@pb);
- if (oe = noErr) & (pb.ioActCount <> len) then begin
- oe := -1;
- end;
- MyFSWriteAt := oe;
- end;
-
- function AEGetParamBoolean (event: AppleEvent; key: AEKeyword; var b: boolean): OSErr;
- var
- realtype: DescType;
- realsize: Size;
- begin
- AEGetParamBoolean := AEGetParamPtr(event, key, typeBoolean, realtype, @b, 1, realsize);
- end; (* AEGetParamBoolean *)
-
- end. (* MungeLibs *)